<%@page import="Dao.scheduledao"%>
<%@page import="Dao.coursedao"%>
<%@page import="Entity.Room_ced"%>
<%@page import="Entity.Course"%>
<%@page import="Entity.User"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'search_class.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha512-SfTiTlX6kk+qitfevl/7LibUOeJWlt9rbyDn92a1DqWOw9vWG2MFoays0sgObmWazO5BQPiFucnnEAjpAB+/Sw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
	<link rel="shortcut icon" type="image/x-icon" href="logo.jpg" />
	<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
	<script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.css">
	<style>
		body {
		  font-family: Arial;
		  background-image: linear-gradient(to top, #e6e9f0 0%, #eef1f5 100%);
		}
		
		* {
		  box-sizing: border-box;
		}
		a {
		text-decoration: none;
		}
		form.example input[type=text] {
		  padding: 10px;
		  font-size: 17px;
		  border: 1px solid grey;
		  float: left;
		  width: 80%;
		  background: #f1f1f1;
		}
		
		form.example button {
		  float: left;
		  width: 20%;
		  padding: 10px;
		  background: #2196F3;
		  color: white;
		  font-size: 17px;
		  border: 1px solid grey;
		  border-left: none;
		  cursor: pointer;
		}
		
		form.example button:hover {
		  background: #0b7dda;
		}
		
		form.example::after {
		  content: "";
		  clear: both;
		  display: table;
		}
	</style>
  </head>
  
  <body>
    <%
    User user =(User) session.getAttribute("user");
  	 if(user==null){
  	 	 request.getRequestDispatcher("login.jsp").forward(request,response);
  	 	 }
  	 	List<Course> courses=(List<Course>)request.getAttribute("courses");
  	 	System.out.print("courses");
  	 	Integer cpage =(Integer) request.getAttribute("cpage");
  	 	System.out.print("cpage");
  	 	Integer totalPage =(Integer) request.getAttribute("sum");
  	 	System.out.print("sum");
  	 %>
    <!-- 顶部-->
    	<div style="border: 1px;display: block;">
    			<image  src="image/title.png" style="width: 600px;">
    			<a href="personInfor.jsp" class="btn dropdown-toggle"  style="float: right;margin:auto 40px;">
    			<i class="fa fa-user-circle fa-2x"></i>
    			个人信息
		   		 </a>
    	</div>
    	<!-- 导航 -->
   		<div style="float: left;width: 10%;height:90%; bottom:0;display: block;border-radius: 10px;
   		background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%);">
   		
   			<ul class="nav nav-pills nav-stacked">
			  <li><a href="RoomServlet"><img src="image/m_1.png" width="25px" style="margin-right: 5px;">机房信息</a></li>
			  <li><a href="SearchServlet?cpage=1">用户信息</a></li>
				  <li class="active">
					<a type="button" class="btn " data-toggle="collapse" 
					    data-target="#demo" >
					     实验安排
					</a>    
					<div id="demo" class="collapse"  style="text-align: center;
						background-image: linear-gradient(to top, #accbee 0%, #e7f0fd 100%);">
					  <a class="btn " href="class_total.jsp" style="color: white;">课程日历</a>
					 <a class="btn " href="searchCourseServlet?page=1" style="color: white;
					  background-image: linear-gradient(to top, #6a85b6 0%, #bac8e0 100%);">查看课程</a>
					</div>
				  <li><a href="EventServlet?page=1">考试/竞赛</a></li>
				  <li><a href="sendmessage.jsp">发件箱</a></li>
			</ul>
			<script type="text/javascript">
				 $(".collapse").collapse('show') 
			</script>
			
		</div>
		<!-- 主体 -->
   		<div style="float: left;width: 90%;margin-left: 10px 0 0 0;">
   			<form class="example" method="post" action="" style="margin:10px auto;max-width:800px">
			  <input type="text" placeholder="搜索.." name="search2">
			  <button type="submit"><i class="fa fa-search"></i></button>
			</form>
	    <table class="table table-striped" style="max-height: 300px;width: 900px; margin:0 auto;">  
            <thead>
                <tr>
                    <th>课程编号</th>
                    <th>课程名称</th>
                    <th>授课老师工号</th>
                    <th>时间</th>
                    <th>操作</th>
                </tr>  
            </thead>
            <tbody id="tablePage">
           
            <%
            	if(courses!=null){
            	scheduledao cour = new scheduledao();
            	
            	for(Course course:courses){
            		String cour_id=course.getCourse_Id();
            		Room_ced ced = cour.getSchedule(cour_id);
            		System.out.print(ced.getDate());
            		%>
            		 <tr>
            		 <td><%=course.getCourse_Id() %></td>
            		 <td><%=course.getCourse_Name() %></td>
            		 <td><%=course.getId() %></td>
            		 <td><%=ced.getDate().toString() %>第<%=ced.getOrder() %>大节</td>
            		 <td><a href="DeleteCourseServlet?cid=<%=course.getCourse_Id() %>">删除</a></td>
            		 </tr>
            		<%
            		}
            	}
             %>
			
            </tbody>    
		</table>  
		<div style="text-align: center;margin: 20px auto;">
		    <%
					if(cpage==1){
						if(totalPage!=1){
					
					%>
							共<%=cpage %>/<%=totalPage %>页
							<a href="searchCourseServlet?page=<%=cpage+1 %>">下一页</a>
							<a href="searchCourseServlet?page=<%=totalPage %>">尾页</a>
					<%
						}else if(totalPage==1){
						%>
							共1/1页
						<%
						}
					}else if(cpage==totalPage){
						%>
							共<%=cpage %>/<%=totalPage %>页
							<a href="searchCourseServlet?page=1">首页</a>
							<a href="searchCourseServlet?page=<%=cpage-1 %>">上一页</a>
						<%
					}else{
						%>
							<a href="searchCourseServlet?page=1">首页</a>
							<a href="searchCourseServlet?page=<%=cpage-1 %>">上一页</a>
							共<%=cpage %>/<%=totalPage %>页
							<a href="searchCourseServlet?page=<%=cpage+1 %>">下一页</a>
							<a href="searchCourseServlet?page=<%=totalPage %>">尾页</a>
						<%
					}
					
				 %>
				</div>
   		</div>
  </body>
</html>
